#define _CRT_SECURE_NO_WARNINGS 1


#include "game.h"

void menu()
{
    printf("*****1. play   2. exit*****");
}

//鹏哥三子棋游戏过程：创造一个二维数组
//人先下，电脑再下，PlayerMove->ComputerMove
//以上过程只有在iswin函数输出了一个值/棋盘满了 这两种情况下，才会停止循环
void game()
{
    char ret = 0;
    char board[ROW][COL] = { 0 };//
    InitBoard(board, ROW, COL);//
    DisplayBoard(board, ROW, COL);//
    while (1)
    {
        PlayerMove(board, ROW, COL);//
        ret = Iswin(board, ROW, COL);//
        if (ret != 'C')
        {
            break;//
        }
        DisplayBoard(board, ROW, COL);//
        ComputerMove(board, ROW, COL);//
        ret = Iswin(board, ROW, COL);//
        if (ret != 'C')
        {
            break;//
        }
        DisplayBoard(board, ROW, COL);//
    }
    if (ret == '*')
    {
        printf("玩家赢了\n");//
    }
    else if (ret == '#')
    {
        printf("电脑赢了\n");//
    }
    else
    {
        printf("平局了\n");//
    }
}

int main()
{
    srand((unsigned int)time(NULL));//
    int input = 0;//
    do
    {
        menu();//
        printf("请选择\n");//
        scanf("%d", &input);//
        switch (input)
        {
        case 1:
            game();//
            break;//
        case 0:
            printf( "退出游戏\n" );//
            break;//
        default:
                printf("输入错误！请重新选择\n");//
        }
    } while (input);//
        return 0;//
}